<template>
	<view :style="{'--price':vuex_config.price}">
		<view class="list" v-if="parameter.layout == 1 || !parameter.layout">
			<view v-for="(item, index) in dataList" :key="index" class="list-item" @click="open(item.pk_id)">
				<image class="list-item-img" :src="item.img?item.img.split(',')[0]:''" mode="aspectFill" />
				<view class="detail">
					<view class="detail-title">{{ item.name }}</view>
					<view class="bot">
						<view class="detail-price">
							{{ item.integral > 0 ? item.integral + '积分' : '' }}
							<template v-if="item.price > 0">
								<text v-if="item.integral > 0">+</text>
								<text class="text_sign">￥</text>
								{{ item.price }}
							</template>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-else-if="parameter.layout == 2" class="row_box">
			<view class="row_item" v-for="(item, index) in dataList" :key="index" @click="open(item.pk_id)">
				<view class="row_img">
					<image :src="item.img?item.img.split(',')[0]:''" mode="aspectFill"></image>
				</view>
				<view class="row_cont">
					<view class="title">{{item.name}}</view>
					<view class="price_box">
						{{ item.integral > 0 ? item.integral + '积分' : '' }}
						<template v-if="item.price > 0">
							<text v-if="item.integral > 0">+</text>
							<text class="text_sign">￥</text>
							<text class="price_num">{{ item.price }}</text>
						</template>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			parameter: {
				type: Object,
				default: () => {
					return {};
				}
			},
			dataList: {
				type: Array,
				default: []
			},
		},
		data() {
			return {};
		},

		methods: {
			open(idx) {
				this.$linkTo(`/package/integral/detail/index?id=${idx}`);
			}
		}
	};
</script>

<style scoped lang="scss">
	.list {
		padding: 10rpx 30rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		.list-item {
			width: 48%;
			border-radius: 13rpx;
			overflow: hidden;
			background-color: #fff;
			margin-bottom: 20rpx;
			box-shadow: 5rpx 5rpx 12rpx 5rpx #eaeaea;

			.list-item-img {
				width: 100%;
				height: 300rpx;
			}

			.detail {
				padding: 20rpx;

				.detail-title {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					width: 100%;
				}

				.bot {
					display: flex;
					align-items: center;

					.detail-price {
						margin-top: 10rpx;
						color: var(--price);
						margin-right: 10rpx;

						.text_sign {
							font-size: 22rpx;
						}
					}
				}
			}
		}
	}

	.row_box {
		background-color: #fff;
		padding: 0 24rpx;

		.row_item {
			padding: 20rpx 0;
			border-bottom: 2rpx solid #f5f5f5;
			display: flex;

			.row_img {
				width: 210rpx;
				height: 210rpx;
				margin-right: 20rpx;
			}

			.row_cont {
				padding-top: 10rpx;
				flex: 1;
				overflow: hidden;
				display: flex;
				flex-direction: column;

				.price_box {
					margin: auto 0;
						color: var(--price);
					.text_sign {
						font-size: 22rpx;
					}

				}
			}
		}
	}
</style>
